package priv.yiyuan.example.design.visitor;

import priv.yiyuan.example.design.visitor.element.ImageElement;
import priv.yiyuan.example.design.visitor.element.TextElement;

/**
 * 导出 MD
 *
 * @author YiYuan
 * @data 2025/7/30
 * @apoNote
 */
public class MarkdownExportVisitor implements DocumentVisitor {

    private StringBuilder output = new StringBuilder();

    public String getOutput() {
        return output.toString();
    }

    @Override
    public void visit(TextElement element) {
        output.append(element.getContent())
                .append("\n\n");
    }

    @Override
    public void visit(ImageElement element) {
        output.append("![")
                .append(element.getAltText())
                .append("](")
                .append(element.getSrc())
                .append(")\n");
    }
}
